package com.ycz.springcloud.config;/*
 @author ycz
 @date 2021-08-22-16:51  
*/

import org.springframework.web.servlet.LocaleResolver;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Locale;

public class MyLocaleResolver implements LocaleResolver {
    @Override
    public Locale resolveLocale(HttpServletRequest request) {
        System.out.println("进来了");
        String language=request.getParameter("l");
        System.out.println(language);
        Locale locale=Locale.getDefault();

        if (language!=null){
            String[] split=language.split("_");
            locale=new Locale(split[0],split[1]);
        }


        return locale;
    }

    @Override
    public void setLocale(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Locale locale) {

    }
}
